#include "../hge-x/include/hge.h"

static HGE *hge = 0;

bool FrameFunc()
{
    hgeTriple triple;

    memset(&triple, 0, sizeof(triple));
    triple.tex = NULL;
    triple.blend = BLEND_DEFAULT;
    triple.v[0].x = 100;
    triple.v[0].y = 100;
    triple.v[0].z = 0.5;
    triple.v[0].col = 0xFFFFFFFF;
    triple.v[1].x = 200;
    triple.v[1].y = 100;
    triple.v[1].z = 0.5;
    triple.v[1].col = 0xFFFFFFFF;
    triple.v[2].x = 150;
    triple.v[2].y = 150;
    triple.v[2].z = 0.5;
    triple.v[2].col = 0xFFFFFFFF;
    hgeGamepad pad;
    hge->Gamepad_GetState(0, &pad);
    hge->Gamepad_Vibration(0, abs((int)(pad.leftThumbX * 32768.0f)), abs((int)(pad.rightThumbX * 32768.0f)));
    hge->Gfx_BeginScene();
    hge->Gfx_Clear(0x221133);
    hge->Gfx_RenderTriple(&triple);
    hge->Gfx_EndScene();
	return false;
}

int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
	hge = hgeCreate(HGE_VERSION);

	hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);

	hge->System_SetState(HGE_WINDOWED, true);
	hge->System_SetState(HGE_TITLE, "test");

	if (hge->System_Initiate())
	{
		hge->System_Start();
	}
	else
	{
		MessageBox(NULL, hge->System_GetErrorMessage(), "Error", MB_OK | MB_ICONERROR | MB_APPLMODAL);
	}
    hge->System_Shutdown();
}